package com.mark.spring.config;

import com.mark.spring.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Created by Choisaaaa on 2018/7/9.
 * 使用配置类注册Bean
 */
@Configuration //说明这是一个配置类
//包扫描
@ComponentScan(value = "com.mark.spring")

//排除某些注解的包扫描
/*@ComponentScan(value = "com.mark.spring" ,excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION,classes ={Controller.class, Service.class})
})*/

//只包含
//@ComponentScan(value = "com.mark.spring" ,includeFilters = {
//        @ComponentScan.Filter(type = FilterType.ANNOTATION,classes ={Controller.class, Service.class})
//},useDefaultFilters = false)
public class MyPersonConfig {

    @Bean //将以返回值为类型，id为方法名的Bean注册到IOC容器中
    //@Bean(name = "personBean") //使用参数设置Bean的Id【name】
    public Person person(){
        return new Person("mark",18);
    }

}
